package com.fms.controllers;

import com.fms.model.BKCashReceiptJournalModel;
import com.fms.dao.BKCashReceiptJournalDAO;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;

public class BKCashReceiptJournal extends WebPage{
	
	private Model bkcrj_idModel = new Model();
	private Model org_idModel = new Model();
	private Model dateModel = new Model();
	private Model particularsModel = new Model();
	private Model assessmentModel = new Model();
	private Model finesModel = new Model();
	private Model interest_depositsModel = new Model();
	private Model donation_solicitationModel = new Model();
	private Model date_createdModel = new Model();
	private Model uploaderModel = new Model();
	private Model statusModel = new Model();
	
	public BKCashReceiptJournal(){
		
		Form bkCashReceiptJournalForm = new Form("bkCashReceiptJournalForm");
		
		TextField bkcrj_id = new TextField("bkcrj_id", bkcrj_idModel);
		bkcrj_id.setRequired(true);
		bkCashReceiptJournalForm.add(bkcrj_id);
		
		TextField org_id = new TextField("org_id", org_idModel);
		org_id.setRequired(true);
		bkCashReceiptJournalForm.add(org_id);
		
		TextField date = new TextField("date", dateModel);
		date.setRequired(true);
		bkCashReceiptJournalForm.add(date);
		
		
		TextField particulars = new TextField("particulars", particularsModel);
		particulars.setRequired(true);
		bkCashReceiptJournalForm.add(particulars);
		
		TextField assessment = new TextField("assessment", assessmentModel);
		assessment.setRequired(true);
		bkCashReceiptJournalForm.add(assessment);
		
		TextField fines = new TextField("fines", finesModel);
		fines.setRequired(true);
		bkCashReceiptJournalForm.add(fines);
		
		TextField interest_deposits = new TextField("interest_deposits", interest_depositsModel);
		interest_deposits.setRequired(true);
		bkCashReceiptJournalForm.add(interest_deposits);
		
		TextField donation_solicitation = new TextField("donation_solicitation", donation_solicitationModel);
		donation_solicitation.setRequired(true);
		bkCashReceiptJournalForm.add(donation_solicitation);
		
		TextField date_created = new TextField("date_created", date_createdModel);
		date_created.setRequired(true);
		bkCashReceiptJournalForm.add(date_created);
		
		TextField uploader = new TextField("uploader", uploaderModel);
		uploader.setRequired(true);
		bkCashReceiptJournalForm.add(uploader);
		
		TextField status = new TextField("status", statusModel);
		status.setRequired(true);
		bkCashReceiptJournalForm.add(status);
		
		add(bkCashReceiptJournalForm);
		
		Button bkCashReceiptJournalAdd = new Button ("bkCashReceiptJournalFormAdd"){
			
			public void onSubmit(){
				String nbkcrj_id = (String) bkcrj_idModel.getObject();
				String norg_id = (String) org_idModel.getObject();
				String date = (String) dateModel.getObject();
				String particulars = (String) particularsModel.getObject();
				String nassessment = (String) assessmentModel.getObject();
				String nfines = (String) finesModel.getObject();
				String ninterest_deposits  = (String) interest_depositsModel.getObject();
				String ndonation_solicitation = (String) donation_solicitationModel.getObject();
				String date_created = (String) date_createdModel.getObject();
				String uploader = (String) uploaderModel.getObject();
				String status = (String) statusModel.getObject();
				
				int bkcrj_id = Integer.parseInt(nbkcrj_id);
				int org_id = Integer.parseInt(norg_id);
				float assessment = Float.valueOf(nassessment);
				float fines = Float.valueOf(nfines);
				float interest_deposits = Float.valueOf(ninterest_deposits);
				float donation_solicitation = Float.valueOf(ndonation_solicitation);
				
				BKCashReceiptJournalModel bkCRJ = new BKCashReceiptJournalModel(bkcrj_id, org_id, date, particulars, assessment,
						fines, interest_deposits, donation_solicitation, date_created, uploader, status);
				
				BKCashReceiptJournalDAO bkCRJDAO = new BKCashReceiptJournalDAO();
				bkCRJDAO.insert(bkCRJ);
				
			}
		};
		
	}

}
